home *** CD-ROM | disk | FTP | other *** search
/ American History: Interactive Maps & User's Guide / American History: Interactive Maps & User's Guide.iso / pc / TIMESCPE.dxr / 00163_File IO Handlers.ls < prev    next >
Encoding:
Text File  |  2000-01-25  |  6.2 KB  |  231 lines

  1. on myPath
  2.   set myFile to new(xtra("fileio"))
  3.   setFilterMask(myFile, EMPTY)
  4.   set fileName to displayOpen(myFile)
  5. end
  6.  
  7. on CreateInitFiles
  8.   global gInitText, gInitState, gFolderName, gFileName, gOutText, gDelimiter, gDataPath, gTeacherCD
  9.   set errorcode to 0
  10.   if the last char in gInitText = RETURN then
  11.     set errorcode to 1
  12.   end if
  13.   if errorcode = 0 then
  14.     if the platform contains "Windows" then
  15.       set Pathname1 to "C:\WINDOWS\"
  16.     else
  17.       set checkpref to misc_x(mnew)
  18.       set Pathname1 to checkpref(mPrefsFolder)
  19.     end if
  20.     set gFolderName to "eapinit.ctx"
  21.     set errorcode to CreateDirectory(Pathname1 & "eapinit.ctx")
  22.     if errorcode <> 0 then
  23.       set errorcode to 2
  24.     end if
  25.   end if
  26.   if errorcode = 0 then
  27.     set gFileName to "eap.ini"
  28.     set gOutText to gInitText
  29.     if (gInitState = 124) or (gInitState = 127) then
  30.       if char length(gOutText) - 8 to length(gOutText) of gOutText = ("eapscore" & gDelimiter) then
  31.         set gOutText to char 1 to length(gOutText) - 9 of gOutText
  32.         set errorcode to 0
  33.       else
  34.         set errorcode to 3
  35.       end if
  36.       set gDataPath to gOutText
  37.     end if
  38.     if errorcode = 0 then
  39.       set errorcode to createText(Pathname1)
  40.       if errorcode = 0 then
  41.         set errorcode to writeText(Pathname1)
  42.         if errorcode <> 0 then
  43.           set errorcode to 5
  44.         end if
  45.       else
  46.         set errorcode to 4
  47.       end if
  48.     end if
  49.   end if
  50.   if (errorcode = 0) and ((gInitState = 123) or (gInitState = 125) or (gInitState = 126)) then
  51.     if the platform contains "Windows" then
  52.       set Pathname2 to line 2 of gOutText
  53.     else
  54.       set checkpref to misc_x(mnew)
  55.       set Pathname2 to line 2 of gOutText
  56.     end if
  57.     set gFolderName to "eapscore"
  58.     set errorcode to CreateDirectory(Pathname2 & "eapscore")
  59.     if errorcode <> 0 then
  60.       set errorcode to 6
  61.     else
  62.       set gDataPath to Pathname2
  63.     end if
  64.   end if
  65.   if (errorcode = 0) and ((gInitState = 123) or (gInitState = 125) or (gInitState = 126)) then
  66.     if the platform contains "Windows" then
  67.       set Pathname3 to Pathname2 & "eapscore\"
  68.     else
  69.       set checkpref to misc_x(mnew)
  70.       set Pathname3 to Pathname2 & "eapscore:"
  71.     end if
  72.     set gFolderName to "Class"
  73.     set errorcode to CreateDirectory(Pathname3 & "Class")
  74.     if errorcode <> 0 then
  75.       set errorcode to 7
  76.     end if
  77.   end if
  78.   if (errorcode = 0) and ((gInitState = 123) or (gInitState = 125) or (gInitState = 126)) then
  79.     set gFileName to "Token"
  80.     set gOutText to "[0,0]"
  81.     set errorcode to createText(Pathname3)
  82.     if errorcode = 0 then
  83.       set errorcode to writeText(Pathname3)
  84.       if errorcode <> 0 then
  85.         set errorcode to 9
  86.       end if
  87.     else
  88.       set errorcode to 8
  89.     end if
  90.   end if
  91.   if errorcode = 0 then
  92.     case gTeacherCD of
  93.       0:
  94.         PopUpWinCall(12, "Y", "Setup Complete")
  95.       1:
  96.         PopUpWinCall(12, "Y", "Setup Complete-Teacher")
  97.     end case
  98.   else
  99.     if errorcode > 8 then
  100.       DeleteFile(Pathname3 & "Class" & gDelimiter & "Token")
  101.     end if
  102.     if errorcode > 7 then
  103.       DeleteDirectory(Pathname3 & "Class")
  104.     end if
  105.     if errorcode > 6 then
  106.       DeleteDirectory(Pathname3)
  107.     end if
  108.     if errorcode > 4 then
  109.       DeleteFile(Pathname1 & "eapinit.ctx" & gDelimiter & "eap.ini")
  110.     end if
  111.     if errorcode > 2 then
  112.       DeleteDirectory(Pathname1 & "eapinit.ctx")
  113.     end if
  114.     case gTeacherCD of
  115.       0:
  116.         PopUpWinCall(12, "Y", "Setup Error")
  117.       1:
  118.         PopUpWinCall(12, "Y", "Setup Error-Teacher")
  119.     end case
  120.   end if
  121. end
  122.  
  123. on selectFolder thePath
  124.   global gPickFolderObject
  125.   if not stringp(thePath) then
  126.     set thePath to the pathName
  127.   end if
  128.   insurePickFolder()
  129.   set theFolder to gPickFolderObject(mGetSelectedFolder, thePath)
  130.   if theFolder = EMPTY then
  131.     set theErr to gPickFolderObject(mError)
  132.     if theErr <> 9 then
  133.       alert("selectFolder() error: " & gPickFolderObject(mErrorString))
  134.     end if
  135.   end if
  136.   return theFolder
  137. end
  138.  
  139. on pickFolderError
  140.   global gPickFolderObject
  141.   insurePickFolder()
  142.   return gPickFolderObject(mError)
  143. end
  144.  
  145. on pickFolderErrorString
  146.   global gPickFolderObject
  147.   insurePickFolder()
  148.   return gPickFolderObject(mErrorString)
  149. end
  150.  
  151. on openPickFolder
  152.   if objectp(factory("PickFolder")) then
  153.     return 1
  154.   end if
  155.   if the machineType < 256 then
  156.     openXLib("PickFolder XObject")
  157.   else
  158.     openXLib("pickfold.dll")
  159.   end if
  160.   if not objectp(factory("PickFolder")) then
  161.     alert("PickFolder XObject didn't register.")
  162.     return 0
  163.   end if
  164.   return 1
  165. end
  166.  
  167. on closePickFolder
  168.   global gPickFolderObject, gVoid
  169.   if objectp(gPickFolderObject) then
  170.     gPickFolderObject(mdispose)
  171.   end if
  172.   if not objectp(factory("PickFolder")) then
  173.     return 1
  174.   end if
  175.   if the machineType < 256 then
  176.     closeXLib("PickFolder XObject")
  177.   else
  178.     closeXLib("pickfold.dll")
  179.   end if
  180.   if objectp(factory("PickFolder")) then
  181.     alert("PickFolder XObject wouldn't close.")
  182.     return 0
  183.   end if
  184.   return 1
  185. end
  186.  
  187. on insurePickFolder
  188.   global gPickFolderObject
  189.   if objectp(gPickFolderObject) then
  190.     return 1
  191.   end if
  192.   if not openPickFolder() then
  193.     alert("insurePickFolder(): openPickFolder() failed")
  194.     abort()
  195.   end if
  196.   set gPickFolderObject to PickFolder(mnew)
  197.   if not objectp(gPickFolderObject) then
  198.     alert("insurePickFolder(): couldn't create object")
  199.     abort()
  200.   end if
  201.   return 1
  202. end
  203.  
  204. on xobjectLoaded theName
  205.   if not stringp(theName) then
  206.     alert("xobjectLoaded(): theName not a string")
  207.     return 0
  208.   end if
  209.   if objectp(factory(theName)) then
  210.     return 1
  211.   end if
  212.   return 0
  213. end
  214.  
  215. on InitSections
  216.   global g1SectionList, g2SectionList, g3SectionList, g4SectionList, g5SectionList, g6SectionList, g7SectionList, g8SectionList, g12SectionList, g13SectionList, g9SectionList, g10SectionList, g11SectionList
  217.   set g1SectionList to list(0, 0, 0, 0)
  218.   set g2SectionList to list(0, 0, 0, 0)
  219.   set g3SectionList to list(0, 0, 0, 0)
  220.   set g4SectionList to list(0, 0, 0, 0)
  221.   set g5SectionList to list(0, 0, 0, 0)
  222.   set g6SectionList to list(0, 0, 0, 0)
  223.   set g7SectionList to list(0, 0, 0, 0)
  224.   set g8SectionList to list(0, 0, 0, 0)
  225.   set g9SectionList to list(0, 0, 0, 0)
  226.   set g10SectionList to list(0, 0, 0, 0)
  227.   set g11SectionList to list(0, 0, 0, 0)
  228.   set g12SectionList to list(0, 0, 0, 0)
  229.   set g13SectionList to list(0, 0, 0, 0)
  230. end
  231.